package transactionimplementation

import (
	"SoftwareEngineering/TransactionApplication"
	"time"
	"reflect"
	ModelImplementation "SoftwareEngineering/ModelImplementation"
	DataBase "SoftwareEngineering/DataBase"
)	

type ServiceChargeTransaction struct {
	itsDate     time.Time
	itsCharge   float64
	itsMemberId int
}

func (s *ServiceChargeTransaction) Execute() {
	e := DataBase.PayrollDatabase.GetUnionMember(s.itsMemberId)

	af := e.GetAffiliation()

	if reflect.TypeOf(af) == reflect.TypeOf(ModelImplementation.UnionAffiliation{}) {
		uaf := af.(*ModelImplementation.UnionAffiliation)
		uaf.AddServiceCharge(s.itsDate, s.itsCharge)
	}
}
